subroutine check_readlabel(cunit)
  use param
  use global_param,only:n_point_type
  use global_param,only:pdefect
  use label_data_param,only:n_obj_type
  use label_data_param,only:obj_type
  implicit none

  integer,intent(in) :: cunit

  integer :: i,j,k,pos1,pos2
  integer :: in1,in2,in3
  character(len=len_linebuf) :: str

  in1=1
  in2=2
  in3=3

  call log_msg1(cunit,"")
  call log_msg1(cunit,"Checking label file...")
  call log_msg1(cunit,"")

  write(str,'("Number of labels=",i0)') n_obj_type
  call log_msg1_indent(cunit,in1,str)

  ! 1x,i7,1x,i8,m*i7,1x,i8
  write(str,'("index",3x,"name",2x)')
  pos1=14
  do i=1,n_point_type
     pos2=pos1+10
     write(str(pos1+1:pos2),'(i3,"(",a2,")")') &
          i,trim(pdefect(i)%ch)
     pos1=pos2
  end do
  pos2=pos1+9
  write(str(pos1+1:pos2),'(1x,2x,"size",2x)')
  call log_msg1_indent(cunit,in1,str(1:pos2))

  do i=1,n_obj_type
     pos1=16
     ! Original labels
     write(str(1:pos1),'("[",i5.5,"]",1x,a8)') i,obj_type(i)%name
     ! Configuration 
     do j=1,n_point_type
        pos2=pos1+10
        write(str(pos1+1:pos2),'(3x,i7)') obj_type(i)%config(j)
        pos1=pos2
     end do
     ! Total size
     pos2=pos1+9
     write(str(pos1+1:pos2),'(1x,i8)') obj_type(i)%total_size
     ! write the label info.
     call log_msg1_indent(cunit,in1,str(1:pos2))

     ! Groups
     write(str,'("> Number of involved groups=",i0)') &
          obj_type(i)%n_group_belong
     call log_msg1_indent(cunit,in2,str)

     pos1=0
     do j=1,obj_type(i)%n_group_belong
        pos2=pos1+3
        write(str(pos1+1:pos2),'(i2,",")') &
             obj_type(i)%group_list(j)
        pos1=pos2
     end do
     call log_msg1_indent(cunit,in2,str(1:pos2))

     ! Motion
     write(str,'("> Motion type=",i0)') &
          obj_type(i)%motion_type
     call log_msg1_indent(cunit,in2,str)
  end do

  return

end subroutine check_readlabel
